/*
 *  KothColours.c
 *  wolf3d
 *
 *  Created by James Weatherley on 26/11/2009.
 *  Copyright 2009 James Weatherley. All rights reserved.
 *
 */

#import "JWUtilities.h"
#include "KothColours.h"
#include <stdlib.h>

void initKothColours()
{
	// These colours never change.
	bark[0] = 0.8f;
	bark[1] = 0.4f;
	bark[2] = 0.0f;
	
	selectedColour[0] = 0.8f;
	selectedColour[1] = 0.0f;
	selectedColour[2] = 0.0f;
	
	robotColour[0] = 0.8f;
	robotColour[1] = 0.8f;
	robotColour[2] = 0.8f;
	
	robotWinColour[0] = 1.0f;
	robotWinColour[1] = 1.0f;
	robotWinColour[2] = 0.0f;
	
	bossColour[0] = 0.2f;
	bossColour[1] = 0.2f;
	bossColour[2] = 0.2f; 
	
	sentinelColour[0] = 0.8f;
	sentinelColour[1] = 0.0f;
	sentinelColour[2] = 0.8f; 
	
	// Blue meanies :)
	meanieColour[0] = 0.0f;
	meanieColour[1] = 0.0f;
	meanieColour[2] = 0.8f; 
	
	visorColour[0] = 1.0f;
	visorColour[1] = 1.0f;
	visorColour[2] = 0.0f;
	
	sideColour[0][0] = 0.54f;
	sideColour[0][1] = 0.33f;
	sideColour[0][2] = 0.27f;
	
	sideColour[1][0] = 0.76f;
	sideColour[1][1] = 0.6f;
	sideColour[1][2] = 0.32f;

	underTreeColour[0] = 0.6f;
	underTreeColour[1] = 0.6f;
	underTreeColour[2] = 0.8f;
	
	// These ones change depending on the level.
	leaf[0] = 0.0f;
	leaf[1] = 0.8f;
	leaf[2] = 0.6f;
	
	sky[0] = 0.7f;
	sky[1] = 0.8f;
	sky[2] = 1.0f;
	
	flatColours[0][0] = 0.4;
	flatColours[0][1] = 1.0;
	flatColours[0][2] = 0.4;
	
	flatColours[1][0] = 0.4;
	flatColours[1][1] = 0.6;
	flatColours[1][2] = 0.4;
	
	cliffColours[0][0] = 0.75;
	cliffColours[0][1] = 0.75;
	cliffColours[0][2] = 0.75;
	
	cliffColours[1][0] = 0.65;
	cliffColours[1][1] = 0.65;
	cliffColours[1][2] = 0.65;
	
	// Lighting - never changes.
	diffuse[0] = diffuse[1] = diffuse[2] = 0.8f;
	specular[0] = specular[1] = specular[2] = 1.0f;
	ambient[0] = ambient[1] = ambient[2] = 0.5f;
}

void setLevelColours(int level)
{
	srandom(level);
	initKothColours();

	if(level != 1) {
		if((random() & 3) == 3) {
			leaf[0] = randomInt(100) / 200.0f + 0.5;
			leaf[1] = randomInt(100) / 200.0f + 0.5;
			leaf[2] = randomInt(100) / 200.0f + 0.5;
		}
		
		sky[0] = randomInt(100) / 100.0f;
		sky[1] = randomInt(100) / 100.0f;
		sky[2] = randomInt(100) / 100.0f;
		
		bool garish = false;
		if((random() & 7) == 7) {
			garish = true;
			cliffColours[0][0] = randomInt(100) / 100.0f;
			cliffColours[0][1] = randomInt(100) / 100.0f;
			cliffColours[0][2] = randomInt(100) / 100.0f;
			
			cliffColours[1][0] = randomInt(100) / 100.0f;
			cliffColours[1][1] = randomInt(100) / 100.0f;
			cliffColours[1][2] = randomInt(100) / 100.0f;
		}
		
		flatColours[0][0] = randomInt(100) / 200.0f + 0.5;
		flatColours[0][1] = randomInt(100) / 200.0f + 0.5;
		flatColours[0][2] = randomInt(100) / 200.0f + 0.5;
		if(garish) {
			flatColours[1][0] = randomInt(100) / 200.0f + 0.5;
			flatColours[1][1] = randomInt(100) / 200.0f + 0.5;
			flatColours[1][2] = randomInt(100) / 200.0f + 0.5;
		} else {
			flatColours[1][0] = flatColours[0][0] * 0.8f;
			flatColours[1][1] = flatColours[0][1] * 0.8f;
			flatColours[1][2] = flatColours[0][2] * 0.8f;
		}
	}
}
